count = 0
for i in range(1,123457):
    if i%3 != 0and i%13 != 0 and i%23!=0:
        count += 1
print(count)